package com.huashi.dealer.modular.business.rebate.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huashi.dealer.commonEntity.UserRebateLog;
import com.huashi.dealer.core.exception.CommonException;
import com.huashi.dealer.core.util.SaTokenUtil;
import com.huashi.dealer.modular.business.rebate.mapper.RebateMapper;
import com.huashi.dealer.modular.business.rebate.service.RebateService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * API返利服务实现类
 *
 * @author 谭陈强
 * @since 2025-07-30
 */
@Service("apiRebateServiceImpl")
public class RebateServiceImpl extends ServiceImpl<RebateMapper, UserRebateLog> implements RebateService {

    @Resource
    private RebateMapper rebateMapper;

    @Override
    public Page<UserRebateLog> getRebateLogList(Page<UserRebateLog> page,Integer time) {
        try {
            // 获取当前登录用户ID
            Long userId = SaTokenUtil.getLoginId();

            // 调用mapper获取返利日志列表
            Page<UserRebateLog> rebateLogPage = rebateMapper.getRebateLogList(userId, page,time);
            return rebateLogPage;
        } catch (Exception e) {
            throw new CommonException("获取返利日志列表失败：" + e.getMessage());
        }
    }
} 